<?php

$name = !empty($_POST["name"]) ? trim($_POST["name"]) : "";
$secondName = !empty($_POST["secondName"]) ? trim($_POST["secondName"]) : "";

if (empty($name) || empty($secondName)) {
	echo "Заполните имя и фамилию!";
	return;
}

$filePath = "./data.txt";

file_put_contents($filePath, PHP_EOL . $name . " " . $secondName, FILE_APPEND);

header("Location: /guestbook/index.php");
